package com.cysion.study.adapter

import android.app.Activity
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.cysion.study.ktbox.base.BaseAdapter
import com.cysion.study.ktbox.base.BaseViewHolder
import com.cysion.other._setOnClickListener
import com.cysion.study.uibox.dialog.Alert
import com.cysion.study.uibox.dialog.CONFIRM
import com.cysion.study.R
import com.cysion.study.entity.ApprovalEntity
import com.cysion.study.widget.ShowToast
import kotlinx.android.synthetic.main.item_pending_ok.view.*

class PendingOkAdapter(mEntities: MutableList<ApprovalEntity>, mContext: Context) :
    BaseAdapter<ApprovalEntity>(mEntities, mContext) {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<ApprovalEntity> {

        return ProMoneyHolder(
            LayoutInflater.from(mContext).inflate(R.layout.item_pending_ok, parent, false)
        )
    }
    class ProMoneyHolder(itemView: View) : BaseViewHolder<ApprovalEntity>(itemView) {
        override fun fillData(obj: ApprovalEntity, position: Int) {
            itemView?.apply {
                //                itemView.tv_data.text=
                //0.请假 1.报销 2.调休
                if (obj.type == "0") {
                    tv_qj.text="请假"
                }else if (obj.type == "1") {
                    tv_qj.text = "报销"
                } else {
                    tv_qj.text = "调休"
                }
                tv_name.text=obj.name
                tv_submit_time.text=obj.createTime
                tv_start_time.text=obj.startTime
                tv_end_time.text=obj.endTime
                tv_data.text=obj.totalTime
                tv_content.text=obj.remark
                tv_yj.text=obj.remark//审批意见

                tv_appro_num.text= "审批人("+obj.examines?.size+")"
               /* Glide.with(context)
                    .load(obj.examines?.get(0)?.url)
                    .apply(RequestOptions.placeholderOf(R.mipmap.place_holder_big))
                    .apply(RequestOptions.bitmapTransform(RoundTransform(6)))
                    .into(iv_head)*/
                tv_approver.text=obj.examines?.get(0)?.stName
                tv_copy_num.text= "抄送人("+obj.copys?.size+")"
                tv_copyer.text=obj.copys?.get(0)?.stName


                tv_detail._setOnClickListener {
                    Alert.detail(context as Activity, "", "确认删除这个博客吗？") { type, msg ->
                        if (type == CONFIRM) {
                            ShowToast("明细")
                        }
                    }
                }
                //审批状态 :0.审核中 1.审核通过 2.审核不通过  3.撤销
                if (obj.status == "0") {
                    tv_agree.text="审核中"
                }else if (obj.status == "1") {
                    tv_agree.text="审核通过"
                }else if (obj.status == "2") {
                    tv_agree.text="审核不通过"
                }else if (obj.status == "3") {
                    tv_agree.text="撤销"
                }

            }

        }

    }

}



